/**
 */
package mobileXversion1.impl;

import java.util.Collection;

import mobileXversion1.AppMobile;
import mobileXversion1.Component;
import mobileXversion1.MobileXversion1Package;
import mobileXversion1.Setting;
import mobileXversion1.View;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Container</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link mobileXversion1.impl.ContainerImpl#getAppName <em>App Name</em>}</li>
 *   <li>{@link mobileXversion1.impl.ContainerImpl#getViews <em>Views</em>}</li>
 *   <li>{@link mobileXversion1.impl.ContainerImpl#getSettings <em>Settings</em>}</li>
 *   <li>{@link mobileXversion1.impl.ContainerImpl#getComponents <em>Components</em>}</li>
 *   <li>{@link mobileXversion1.impl.ContainerImpl#getMyProfile <em>My Profile</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ContainerImpl extends MinimalEObjectImpl.Container implements mobileXversion1.Container {
	/**
	 * The default value of the '{@link #getAppName() <em>App Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAppName()
	 * @generated
	 * @ordered
	 */
	protected static final String APP_NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getAppName() <em>App Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAppName()
	 * @generated
	 * @ordered
	 */
	protected String appName = APP_NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getViews() <em>Views</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getViews()
	 * @generated
	 * @ordered
	 */
	protected EList<View> views;

	/**
	 * The cached value of the '{@link #getSettings() <em>Settings</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSettings()
	 * @generated
	 * @ordered
	 */
	protected EList<Setting> settings;

	/**
	 * The cached value of the '{@link #getComponents() <em>Components</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComponents()
	 * @generated
	 * @ordered
	 */
	protected EList<Component> components;

	/**
	 * The cached value of the '{@link #getMyProfile() <em>My Profile</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMyProfile()
	 * @generated
	 * @ordered
	 */
	protected AppMobile myProfile;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContainerImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MobileXversion1Package.Literals.CONTAINER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getAppName() {
		return appName;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAppName(String newAppName) {
		String oldAppName = appName;
		appName = newAppName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileXversion1Package.CONTAINER__APP_NAME, oldAppName, appName));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<View> getViews() {
		if (views == null) {
			views = new EObjectContainmentEList<View>(View.class, this, MobileXversion1Package.CONTAINER__VIEWS);
		}
		return views;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Setting> getSettings() {
		if (settings == null) {
			settings = new EObjectContainmentEList<Setting>(Setting.class, this, MobileXversion1Package.CONTAINER__SETTINGS);
		}
		return settings;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Component> getComponents() {
		if (components == null) {
			components = new EObjectContainmentEList<Component>(Component.class, this, MobileXversion1Package.CONTAINER__COMPONENTS);
		}
		return components;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public AppMobile getMyProfile() {
		return myProfile;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMyProfile(AppMobile newMyProfile, NotificationChain msgs) {
		AppMobile oldMyProfile = myProfile;
		myProfile = newMyProfile;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MobileXversion1Package.CONTAINER__MY_PROFILE, oldMyProfile, newMyProfile);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMyProfile(AppMobile newMyProfile) {
		if (newMyProfile != myProfile) {
			NotificationChain msgs = null;
			if (myProfile != null)
				msgs = ((InternalEObject)myProfile).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MobileXversion1Package.CONTAINER__MY_PROFILE, null, msgs);
			if (newMyProfile != null)
				msgs = ((InternalEObject)newMyProfile).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MobileXversion1Package.CONTAINER__MY_PROFILE, null, msgs);
			msgs = basicSetMyProfile(newMyProfile, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MobileXversion1Package.CONTAINER__MY_PROFILE, newMyProfile, newMyProfile));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MobileXversion1Package.CONTAINER__VIEWS:
				return ((InternalEList<?>)getViews()).basicRemove(otherEnd, msgs);
			case MobileXversion1Package.CONTAINER__SETTINGS:
				return ((InternalEList<?>)getSettings()).basicRemove(otherEnd, msgs);
			case MobileXversion1Package.CONTAINER__COMPONENTS:
				return ((InternalEList<?>)getComponents()).basicRemove(otherEnd, msgs);
			case MobileXversion1Package.CONTAINER__MY_PROFILE:
				return basicSetMyProfile(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MobileXversion1Package.CONTAINER__APP_NAME:
				return getAppName();
			case MobileXversion1Package.CONTAINER__VIEWS:
				return getViews();
			case MobileXversion1Package.CONTAINER__SETTINGS:
				return getSettings();
			case MobileXversion1Package.CONTAINER__COMPONENTS:
				return getComponents();
			case MobileXversion1Package.CONTAINER__MY_PROFILE:
				return getMyProfile();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MobileXversion1Package.CONTAINER__APP_NAME:
				setAppName((String)newValue);
				return;
			case MobileXversion1Package.CONTAINER__VIEWS:
				getViews().clear();
				getViews().addAll((Collection<? extends View>)newValue);
				return;
			case MobileXversion1Package.CONTAINER__SETTINGS:
				getSettings().clear();
				getSettings().addAll((Collection<? extends Setting>)newValue);
				return;
			case MobileXversion1Package.CONTAINER__COMPONENTS:
				getComponents().clear();
				getComponents().addAll((Collection<? extends Component>)newValue);
				return;
			case MobileXversion1Package.CONTAINER__MY_PROFILE:
				setMyProfile((AppMobile)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MobileXversion1Package.CONTAINER__APP_NAME:
				setAppName(APP_NAME_EDEFAULT);
				return;
			case MobileXversion1Package.CONTAINER__VIEWS:
				getViews().clear();
				return;
			case MobileXversion1Package.CONTAINER__SETTINGS:
				getSettings().clear();
				return;
			case MobileXversion1Package.CONTAINER__COMPONENTS:
				getComponents().clear();
				return;
			case MobileXversion1Package.CONTAINER__MY_PROFILE:
				setMyProfile((AppMobile)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MobileXversion1Package.CONTAINER__APP_NAME:
				return APP_NAME_EDEFAULT == null ? appName != null : !APP_NAME_EDEFAULT.equals(appName);
			case MobileXversion1Package.CONTAINER__VIEWS:
				return views != null && !views.isEmpty();
			case MobileXversion1Package.CONTAINER__SETTINGS:
				return settings != null && !settings.isEmpty();
			case MobileXversion1Package.CONTAINER__COMPONENTS:
				return components != null && !components.isEmpty();
			case MobileXversion1Package.CONTAINER__MY_PROFILE:
				return myProfile != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (appName: ");
		result.append(appName);
		result.append(')');
		return result.toString();
	}

} //ContainerImpl
